<template>
	<view>
		<s-pull-scroll ref="pullScroll" :pullDown="pullDown" :pullUp="loadData" :back-top="true">
			<view class="list">
				<view class="item items-center justify-between" v-for="item in dataList" :key="item.id">
					<view class="left">
						<image class="image-block" :src="item.icon" mode=""></image>
					</view>
					<view class="right">
						<view class="name">
							{{item.name}}
						</view>
						<view class="tips">
							购买链接：{{item.url}}
						</view>
						<view class="bottom items-center">
							<view class="btn" @click="setClipboardData(item.url)">
								复制
							</view>
						<!-- 	<view class="btn btn-1" @click="handleOpen(item.url)">
								打开
							</view> -->
						</view>
					</view>
				</view>
			</view>
		</s-pull-scroll>
		<mix-loading v-if="isLoading"></mix-loading>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList:[]
			};
		},
		onLoad() {
			this.refresh();
		},
		methods:{
			handleOpen(url){
				// #ifdef MP-WEIXIN
				this.setClipboardData(url)
				// #endif
				// #ifndef MP-WEIXIN
				plus.runtime.openURL(url)
				// #endif
			},
			pullDown(pullScroll) {
				setTimeout(() => {
					this.loadData(pullScroll);
				}, 200);
			},
			async loadData(pullScroll) {
				const data = {
					uid: uni.getStorageSync('uid'),
					pageNo: pullScroll.page,
					pageSize: '10'
				};
				if (pullScroll.page == 1) this.dataList = [];
				const res = await this.$request('user/card-buy', data, { showLoading: true });
				if (res.result == 0) {
					this.dataList = this.dataList.concat(res.data.list);
					pullScroll.endByPage(Math.ceil(res.data.count / 10), res.data.list);
				} else {
					this.$util.msg(res.resultNote);
				}
			},
		},
	}
</script>

<style lang="scss" scoped> 
	.list{
		padding: 30rpx;
		.item{
			background: #FFFFFF;
			border-radius: 20rpx;
			padding: 30rpx;
			margin-bottom: 30rpx;
			.left{
				width: 180rpx;
				height: 160rpx;
				.image-block{
					width: 100%;
					height: 100%;
					border-radius: 14rpx;
				}
			}
			.right{
				width: 68%;
				.name{
					font-size: 34rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #333333;
				}
				.tips{
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #666666;
					margin: 10rpx 0 20rpx;
				}
				.bottom{
					.btn{
						width: 130rpx;
						height: 55rpx;
						background: #FFF;
						border: 2rpx solid $uni-color-bg;
						border-radius: 28rpx;
						font-size: 26rpx;
						font-family: PingFang SC;
						font-weight: bold;
						color: $uni-color-bg;
						line-height: 55rpx;
						text-align: center;
					}
					.btn-1{
						background: #E4EEFF;
						border: 2rpx solid #446CB2;
						color: #446CB2;
						margin-left: 20rpx;
					}
				}
			}
		}
	}
</style>
